package com.jiuzhi.app.controller;

import java.util.List;

import com.jiuzhi.app.domain.NcpOwner;
import com.jiuzhi.app.service.INcpOwnerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jiuzhi.common.annotation.Log;
import com.jiuzhi.common.enums.BusinessType;
import com.jiuzhi.common.core.controller.BaseController;
import com.jiuzhi.common.core.domain.AjaxResult;
import com.jiuzhi.common.utils.poi.ExcelUtil;
import com.jiuzhi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author jiuzhi
 * @date 2020-02-15
 */
@Controller
@RequestMapping("/system/owner")
public class NcpOwnerController extends BaseController
{
    private String prefix = "system/owner";

    @Autowired
    private INcpOwnerService ncpOwnerService;


    @GetMapping()
    public String owner()
    {
        return prefix + "/owner";
    }

    /**
     * 查询【请填写功能名称】列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(NcpOwner ncpOwner)
    {
        startPage();
        List<NcpOwner> list = ncpOwnerService.selectNcpOwnerList(ncpOwner);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */

    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(NcpOwner ncpOwner)
    {
        List<NcpOwner> list = ncpOwnerService.selectNcpOwnerList(ncpOwner);
        ExcelUtil<NcpOwner> util = new ExcelUtil<NcpOwner>(NcpOwner.class);
        return util.exportExcel(list, "owner");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */

    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(NcpOwner ncpOwner)
    {
        return toAjax(ncpOwnerService.insertNcpOwner(ncpOwner));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        NcpOwner ncpOwner = ncpOwnerService.selectNcpOwnerById(id);
        mmap.put("ncpOwner", ncpOwner);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */

    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(NcpOwner ncpOwner)
    {
        return toAjax(ncpOwnerService.updateNcpOwner(ncpOwner));
    }

    /**
     * 删除【请填写功能名称】
     */

    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ncpOwnerService.deleteNcpOwnerByIds(ids));
    }
}
